import { UserCollection } from "./UserCollection";
import { User } from "./User";

// 创建几个用户
const alice = new User("Alice");
const bob = new User("Bob");
const carol = new User("Carol");

// 创建一个用户集合
const userCollection = new UserCollection();
userCollection.addFriend(alice);
userCollection.addFriend(bob);
userCollection.addFriend(carol);

// 接下来我们想要遍历该集合
const iterator = userCollection.createIterator();
while (iterator.hasMore()) {
  const user = iterator.getNext();
  console.log(user?.name);
}
